#ifndef DATA_BEAN_H
#define DATA_BEAN_H

#include <QVector>
#include <QJsonObject>
#include <QString>
#include <QDateTime>
#include <QMap>
#include <QJsonArray>

enum TASK_STATE {
    ACTIVE,
    COMPLETED
};

enum USER_ROLE {
    STUDENT,
    TEACHER,
    MANAGER
};

class Serializable {
public:
    QJsonObject to_json();
};

class User : public Serializable {
public:
    User() {}
    User(QString id, QString password, USER_ROLE role, QString e_mail, QString phone);

    QString getPassword() const;
    void setPassword(const QString &value);

    QString getEmail() const;
    void setEmail(const QString &value);

    QString getPhone() const;
    void setPhone(const QString &value);

    USER_ROLE getRole() const;
    void setRole(const USER_ROLE &value);

    QString getId() const;
    void setId(const QString &value);

    bool operator== (const User& user);
    bool operator== (const QString& str);

    QJsonObject to_json();

private:
    QString id;
    QString password;
    QString email;
    QString phone;
    USER_ROLE role;
};

class Group : public Serializable {
public:
    Group() {}
    Group(QString gid, QString gname, QString mgr);

    QString getGroup_name() const;
    void setGroup_name(const QString &value);

    QString getGroup_manager() const;
    void setGroup_manager(const QString &value);

    bool operator== (const Group& group);
    bool operator== (const QString& str);

    QString getGroup_id() const;

    void add_user(const QString& uid);
    bool remove_user(const QString& uid);

    QVector<QString>& getMembers();

    int get_member_size();

    QJsonObject to_json();

private:
    QVector<QString> members;
    QString group_id;
    QString group_name;
    QString group_manager;
};

class Task : public Serializable {
public:
    Task() {}
    Task(QString tid, QString tname, QString owner, QDateTime begin_time, QDateTime end_time, QString save_path, TASK_STATE state);

    QString getTask_name() const;
    void setTask_name(const QString &value);

    QDateTime getEnd_time() const;
    void setEnd_time(const QDateTime &value);

    TASK_STATE getTask_state() const;
    void setTask_state(const TASK_STATE &value);

    QString getSave_path() const;
    void setSave_path(const QString &value);

    bool operator== (const Task& task);
    bool operator== (const QString& str);

    void add_member(const QString& member, const QString& file_name);
    void add_member(Group& group);

    QString getTask_owner() const;

    QMap<QString, QString>& getMember_hand_in_state_map();

    QJsonObject to_json();

private:
    QString task_id;
    QString task_name;
    QString task_owner;
    QDateTime begin_time;
    QDateTime end_time;
    QString save_path;
    TASK_STATE task_state;
    QMap<QString, QString> member_hand_in_state_map;
};

#endif // DATA_BEAN_H
